//
//  JKRFeedDetailTopView.m
//  JKRFeedDemo
//
//  Created by Lucky on 2017/12/9.
//  Copyright © 2017年 Lucky. All rights reserved.
//

#import "JKRFeedDetailTopView.h"
#import "JKRFeedProgressView.h"
#import "JKRFeedStatusView.h"
#import "JKRFeedAuthorTopView.h"
#import "JKRFeedAuthorView.h"
#import "JKRFeedAuthorBottomView.h"
#import "JKRFeedDetailContentView.h"

@interface JKRFeedDetailTopView ()

@property (nonatomic, strong) JKRFeedProgressView *progressView;
@property (nonatomic, strong) JKRFeedStatusView *statusView;
@property (nonatomic, strong) JKRFeedAuthorTopView *topView;
@property (nonatomic, strong) JKRFeedAuthorView *authorView;
@property (nonatomic, strong) JKRFeedAuthorBottomView *bottomView;
@property (nonatomic, strong) JKRFeedDetailContentView *contentView;

@end

@implementation JKRFeedDetailTopView

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    self.backgroundColor = [UIColor colorWithRed:244/255.0 green:247/255.0 blue:248/255.0 alpha:1.0];;
    
    _progressView = [JKRFeedProgressView new];
    _statusView = [JKRFeedStatusView new];
    _topView = [JKRFeedAuthorTopView new];
    _topView.topView = self;
    _authorView = [JKRFeedAuthorView new];
    _authorView.topView = self;
    _bottomView = [JKRFeedAuthorBottomView new];
    _bottomView.topView = self;
    _contentView = [JKRFeedDetailContentView new];
    [self addSubview:_progressView];
    [self addSubview:_statusView];
    [self addSubview:_topView];
    [self addSubview:_authorView];
    [self addSubview:_bottomView];
    [self addSubview:_contentView];
    
    return self;
}

- (void)setLayout:(JKRFeedDetailLayout *)layout {
    _layout = layout;
    self.frame = CGRectMake(0, 0, kScreenWidth, layout.topHeight);
    self.progressView.layout = layout.progressLayout;
    self.statusView.layout = layout.statusLayout;
    self.topView.layout = layout.topLayout;
    self.authorView.layout = layout.authorLayout;
    self.bottomView.layout = layout.bottomLayout;
    self.contentView.layout = layout.contentLayout;
}

@end
